<?php

require_once '../../classes/includeAll_Layer2.php';
//session_start(); //debug
if(!isset($_SESSION["startDate"]) || !isset($_SESSION["expectedResult"]) || !isset($_SESSION["SCPResult"]) || $_SESSION["SCPResult"]==false)
{
  echo "error";
  exit();
}

$search = array ("-", "ae",     "ue",     "oe");
$replace = array(" ", "&auml;", "&uuml;", "&ouml;");
$startDate=$_SESSION["startDate"];
//echo $startDate." ".$_SESSION["expectedResult"]."<br>";
$queries = new mysqlqueries();
$query = $queries->AddLimit($queries->ExtendOrder($queries->ExtendWhere($queries->GetTable($queries->Flag, null), array("name","date"), array("NOT LIKE",">="), array("FullScanProgress",$startDate)),"date DESC"), 0, 1);
//echo $query."<br>";
require '../../resources/getConnection.php';
$result = $connection->query($query);
if($row = mysqli_fetch_array($result))
{
  //$row = mysqli_fetch_array($result);
  if($row["flag"]==$_SESSION["expectedResult"])
  {
    echo 'true';
    exit();
  }
  else
  {
    $notice = "";
    foreach ((new allFlags())->GlobalFlags as $key => $value) {
      if(($row["flag"] & $value)>0)
      {
        $notice.=str_replace($search, $replace, $key).'<br>';
      }
    }
    //echo $notice;
    if(strpos($notice, "Fehler")!==false)
      echo 'error';
    else
      echo 'false';
    exit();
  }
}
  echo 'false';
  exit();
